﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Reflection;

namespace TaskManagement.ashx
{
    /// <summary>
    /// synchronousdata 的摘要说明
    /// </summary>
    public class synchronousdata : IHttpHandler
    {
        HttpResponse Response;
        HttpRequest Request;
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Request = context.Request;
            Response = context.Response;
            string action = context.Request.Params["action"];
            if (action == "synchronousdata")
            {
                string url = Request["url"].ToString();
                //string data = Request["data"].ToString();
                //JavaScriptSerializer js = new JavaScriptSerializer();
                //bill bill = js.Deserialize<bill>(Request["data"].ToString());
                //   List<bill> list = ScriptDeserialize(data);
                Response.Write("1");
            }
        }
        //private List<bill> ScriptDeserialize(string json)
        //{

        //    JavaScriptSerializer js = new JavaScriptSerializer();
        //    object obj = js.DeserializeObject(json);
        //    List<bill> list = new List<bill>();
        //    if (obj.GetType().Name == "Object[]")
        //    {
        //        foreach (object ob in ((object[])obj))
        //        {
        //            bill bill = new synchronousdata.bill();
        //            Dictionary<string, object> dic = ob as Dictionary<string, object>;
        //            foreach (KeyValuePair<string, object> item in dic)
        //            {
        //                if (item.Key == "id")
        //                    bill.id = item.Value.ToString();
        //                if (item.Key == "name")
        //                    bill.name = item.Value.ToString();
        //                if (item.Key == "createtime")
        //                    bill.createtime = item.Value.ToString();
        //                if (item.Key == "price")
        //                    bill.price = item.Value.ToString();
        //                if (item.Key == "details")
        //                    bill.details = item.Value.ToString();
        //            }
        //            list.Add(bill);
        //        }
        //    }
        //    return list;
        //}

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public class bill
        {
            public string id { get; set; }
            public string name { get; set; }
            public string createtime { get; set; }
            public string price { get; set; }
            public string details { get; set; }
        }
    }
}